package openinterface

import (
	"github.com/gin-gonic/gin"
	"github.com/gin-gonic/gin/binding"
	"yundian/internel/app/dao"
	"yundian/internel/pkg/dingo"
	. "yundian/internel/pkg/dingo/result"
)

type DeviceSnGetPlaceInfoResult struct {
	PlaceId string `json:"placeId"`
}

func DeviceSnGetPlaceInfo(c *gin.Context) {
	param := &struct {
		DeviceSn string `json:"deviceSn" form:"DeviceSn" `
	}{}
	dingo.ErrorIf(c.ShouldBindBodyWith(&param, binding.JSON)).Unwrap()
	result := DeviceSnGetPlaceInfoResult{}

	result.PlaceId = dao.NewOpenInterfaceDao().DeviceSnGetPlaceInfo(param.DeviceSn).Unwrap().(string)
	Response(c)("", CodeSuccess, result)(OK)
}
